package com.pizidea.imagepicker.ui.activity;

import androidx.annotation.Nullable;
import com.google.android.material.tabs.TabLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.efounder.frame.baseui.BaseFragment;
import com.efounder.mobilecomps.R;
import com.pizidea.imagepicker.ui.ItemFragment;
import com.pizidea.imagepicker.ui.WorkOrderPeopleDetailFragment;


/**
 * fragmengt 嵌套fragment
 */
public class OrderDetailFragment extends BaseFragment {

    private ViewPager viewPager;
    private TabLayout tablayout;
    private static String[] title = {"工作流程","派工人员"};

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.orderdetail, null);


       viewPager = (ViewPager) rootView.findViewById(R.id.viewPager);
       tablayout = (TabLayout) rootView.findViewById(R.id.tabLayout);

        viewPager.setAdapter(new FragmentPagerAdapter(getActivity().getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                if(position==0){
                    return ItemFragment.newInstance(null);
                }else{

                    return new WorkOrderPeopleDetailFragment();
                }
            }

            @Override
            public int getCount() {
                return 2;
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return title[position];
            }

        });
        tablayout.setupWithViewPager(viewPager);

        return rootView;
    }
}
